package com.suxiaoxiao.springbootlearn.designpattern.adapterpattern.objectadapter.turykey;

import com.suxiaoxiao.springbootlearn.designpattern.adapterpattern.objectadapter.ducks.Duck;

/**
 * 适配器
 * 火鸡适配鸭子的行为
 * @author 、
 */
public class TurkeyAdapter implements Duck {

    /**
     * 火鸡
     */
    Turkey turkey;

    public TurkeyAdapter(Turkey turkey) {
        this.turkey = turkey;
    }

    /**
     * 实际上是调用火鸡叫
     */
    @Override
    public void quack() {
        turkey.gobble();
    }

    /**
     * 调用火鸡飞
     * 火鸡飞的短 为了适配 鸭子飞 所以连续调用5次
     */
    @Override
    public void fly() {
        for (int i = 0; i < 5; i++) {
            turkey.fly();
        }
    }

}
